import * as constants from 'src/AppConstants'

import {mapActions} from 'vuex'

import moment from 'moment'

export default {
    filters: {
        formatDate(dateStr,patten) {
            if (!dateStr) {
                return ''
            }
            return moment(dateStr).format(patten || 'YYYY-MM-DD HH:mm')
        }
    },
    methods: {
        ...mapActions([
            'updateHeader',
            'updateFooter',
            'showToast'
        ]),
        buildBackgroundUrl(url) {
            return `url(${url})`
        },
        getAvatar(avatar) {
            return avatar || constants.DEFAULT_AVATAR
        }
    }
}
